package com.preknow.oop;

public class ObjectArray {

    public Student getAllMessage(Student[] array) {
        for (int i = 0; i < array.length; i++) {
            Student s = array[i];
            System.out.println(s.getName() + "---" + s.getAge());
            System.out.println("----------------------------------------------");
            for (Student ss : array) {
                System.out.println(ss.getName() + "----" + s.getAge());
            }
        }
        return null;
    }
    public Student[] getAll(){
        //1.创建一个Student类型数组容器
        Student[] array = new Student[2];
        //2.创建两个学生对象
        Student s1 = new Student();
        s1.setName("Tom");
        s1.setAge(20);

        Student s2 = new Student();
        s2.setName("friend");
        s2.setAge(30);
        //3.将对象保存到数组中
        array[0] = s1;
        array[1] = s2;
        return array;
    }
    public static void main(String[] args) {
             //创建ObjectArry类的对象
            ObjectArray objectArray = new ObjectArray();
            Student[] ss = objectArray.getAll();
            //4.遍历数组获取数组中的Student对象信息
           //objectArray.getAllMessage(array);

        }
    }

